﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace com.guysherman.simulclass
{
    public class AssemblyScanner
    {
        public string AssemblyPath { get; set; }
        public string OutputDirectory { get; set; }
        public string HeaderPreamble { get; set; }
        public string IncludeFile { get; set; }
        public string BodyIncludeFile { get; set; }

        public void GenerateClassesInAssembly()
        {
            Assembly assembly = Assembly.LoadFile(AssemblyPath);

            foreach (Type t in assembly.GetTypes())
            {
               

                    Console.WriteLine(t.FullName);
                    ScannedClass c = new ScannedClass(t, HeaderPreamble, IncludeFile, BodyIncludeFile);
                    File.WriteAllText(Path.Combine(OutputDirectory, string.Format("{0}.h", t.Name.Replace('.', '_'))), c.Header());
                    File.WriteAllText(Path.Combine(OutputDirectory, string.Format("{0}.cpp", t.Name.Replace('.', '_'))), c.Definition());
                
            }
        }
    }
}
